package com.micro.glszh.stat.controller;

import com.micro.glszh.stat.base.CommonResult;
import com.micro.glszh.stat.domain.BizMatterDetail;
import com.micro.glszh.stat.interceptor.AuthCheck;
import com.micro.glszh.stat.service.BizMatterDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * BizMatterDetailController
 *
 * @Author gaopengfei
 * @create 2024/10/21 16:11
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = "事假")
@RequestMapping("/api/bizMatterDetail")
public class BizMatterDetailController {

    private final BizMatterDetailService bizMatterDetailService;

    @AuthCheck
    @ApiOperation("删除一条事假")
    @DeleteMapping("/{id}")
    public CommonResult<Boolean> deleteMatterDetail(@PathVariable Long id) {
        return CommonResult.success(bizMatterDetailService.removeById(id));
    }

    @AuthCheck
    @ApiOperation("根据recordId 获取事件列表")
    @GetMapping("/{recordId}")
    public CommonResult<List<BizMatterDetail>> selectMatterDetailList(@PathVariable Long recordId) {
        return CommonResult.success(bizMatterDetailService.selectMatterDetailList(recordId));
    }

    @AuthCheck
    @ApiOperation("新增或修改用户")
    @PostMapping()
    public CommonResult<Boolean> insertOrUpdateMatterDetail(@Validated @RequestBody List<BizMatterDetail> bizMatterDetailList) {
        return CommonResult.success(bizMatterDetailService.saveOrUpdateBatch(bizMatterDetailList));
    }
}
